//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<IBlendState.h>
///	@path	~/src/graphics/
///	@date	2008/12/22
///	@desc	.

#pragma once

#include "graphics/IDevice.h"

namespace xeres {

	// forward declaration
	class RenderContext;

	enum BlendOpType
	{
		BLENDOP_ADD		= 0,
		BLENDOP_SUB		= 1,
		BLENDOP_RSUB	= 2,
		BLENDOP_MIN		= 3,
		BLENDOP_MAX		= 4,
		BLENDOP_last
	};

	enum BlendType
	{
		BLEND_ZERO			= 1,
		BLEND_ONE			= 2,
		BLEND_SRCCOLOR		= 3,
		BLEND_INVSRCCOLOR	= 4,
		BLEND_SRCALPHA		= 5,
		BLEND_INVSRCALPHA	= 6,
		BLEND_DESTALPHA		= 7,
		BLEND_INVDESTALPHA	= 8,
		BLEND_DESTCOLOR		= 9,
		BLEND_INVDESTCOLOR	= 10,
		BLEND_SRCALPHASAT	= 11,
		BLEND_BLENDFACTOR	= 12,
		BLEND_INVBLENDFACTOR = 13,
		BLEND_last
	};

	enum ColorWrite
	{
		COLOR_WRITE_RED		= 1,
		COLOR_WRITE_GREEN	= 2,
		COLOR_WRITE_BLUE	= 4,
		COLOR_WRITE_ALPHA	= 8,
		COLOR_WRITE_ALL = ( COLOR_WRITE_RED | COLOR_WRITE_GREEN | COLOR_WRITE_BLUE | COLOR_WRITE_ALPHA ),
		COLOR_WRITE_last
	};

	struct BlendSet
	{
		bool		enable_blend[8];
		bool		separate_alpha;
		bool		alpha_to_coverage;
		bool		spare[2];
		
		BlendOpType	color_op;
		BlendType	color_src;
		BlendType	color_dst;

		BlendOpType	alpha_op;
		BlendType	alpha_src;
		BlendType	alpha_dst;

		uint8		color_write[8];
	};

	/*! 
		\class	IBlendState
		\brief
	*/
	class IBlendState : public IObject
	{
	public:

		/// \ctor
		IBlendState( void );

		/// \dtor
		virtual ~IBlendState( void );

		DECL_IOBJECT_INTERFACE( IBlendState , IObject );

	public:

		/// \brief	Apply blend state.
		virtual void Apply( RenderContext& rc ) = 0;
	};

} // namespace xeres
